import request from '@/utils/request'

const deptApi = process.env.VUE_APP_SYS_API + '/dept'

/**
 * 返回数结构
 * @param params
 * @returns {AxiosPromise}
 */
export const getDeptTrees = (params) => {
  return request({
    url: `${deptApi}/trees`,
    method: 'GET',
    params
  })
}
/**
 * 单条查询部门
 * @param id
 * @returns {AxiosPromise}
 */
export const getDeptById = (id) => {
  return request({
    url: `${deptApi}/${id}`,
    method: 'GET',
  })
}

/**
 * 修改部门
 * @param data 部门参数
 * @returns {AxiosPromise}
 */
export const updateDept = (data) => {
  return request({
    url: `${deptApi}/${data.id}`,
    method: 'PUT',
    data
  })
}

/**
 * 添加新部门
 * @param data 部门参数
 * @returns {AxiosPromise}
 */
export const addDept = (data) => {
  return request({
    url: `${deptApi}`,
    method: 'POST',
    data
  })
}

/**
 * 删除部门
 * @param id 部门id
 * @returns {AxiosPromise}
 */
export const delDept = (id) => {
  return request({
    url: `${deptApi}/${id}`,
    method: 'DELETE'
  })
}

